package com.yuqiao.read.design.iterator;

import java.util.Iterator;

public class Waitress {
    Menu dinerMenu;
    Menu pancakeHouseMenu;
    Menu cafeMenu;

    public Waitress(Menu dinerMenu,Menu pancakeHouseMenu,Menu cafeMenu){
        this.dinerMenu = dinerMenu;
        this.pancakeHouseMenu = pancakeHouseMenu;
        this.cafeMenu = cafeMenu;
    }


    public void printMenu(){
        Iterator dinerMenuIterator = dinerMenu.createIterator();
        Iterator pancakeHouseMenuIterator = pancakeHouseMenu.createIterator();
        Iterator ca = cafeMenu.createIterator();
        printMenu(dinerMenuIterator);
        printMenu(pancakeHouseMenuIterator);
        printMenu(ca);
    }

    private void printMenu(Iterator iterator){
        while (iterator.hasNext()){
            MenuItem menuItem = (MenuItem) iterator.next();
            System.out.println("iterator = [" + menuItem.getName() + "]");
            System.out.println("iterator = [" + menuItem.getPrice() + "]");
            System.out.println("iterator = [" + menuItem.getDescription() + "]");
        }
    }
}
